package model

import (
	"gorm.io/gorm"
	"time"
)

type BaseModel struct {
	ID        int32          `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `gorm:"column:add_time" json:"-"`
	UpdatedAt time.Time      `gorm:"column:update_time" json:"-"`
	DeletedAt gorm.DeletedAt `json:"-"`
	IsDeleted bool           `json:"-"`
}

// 购物车表
type ShoppingCart struct {
	BaseModel
	UserId  int   `gorm:"type:int;index"`
	GoodsId int   `gorm:"type:int;index"`
	Nums    int32 `gorm:"type:int"`
	Checked bool
}

// 订单信息表
type OrderInfo struct {
	BaseModel
	UserId       int       `gorm:"type:int;index;comment:用户ID"`
	OrderSn      string    `gorm:"type:varchar(100);index;comment:订单编号"`
	PayType      int8      `gorm:"type:tinyint(1);comment:1(支付宝支付),2(微信支付)"`
	Status       string    `gorm:"type:varchar(20);comment:支付状态,PAYING(待支付), TRADE_SUCCESS(成功)， TRADE_CLOSED(超时关闭), WAIT_BUYER_PAY(交易创建), TRADE_FINISHED(交易结束)"`
	TradeNo      string    `gorm:"type:varchar(100);comment:交易号"`
	OrderMount   float32   `gorm:"type:decimal(10,2);comment:订单金额"`
	PayTime      time.Time `gorm:"comment:支付时间"`
	Address      string    `gorm:"type:varchar(100);comment:收货地址"`
	SingerName   string    `gorm:"type:varchar(20);comment:收货人"`
	SingerMobile string    `gorm:"type:char(11);comment:收货人号码"`
	Post         string    `gorm:"type:varchar(20);comment:订单备注"`
}

// 订单商品表
type OrderGoods struct {
	BaseModel
	OrderId    int     `gorm:"type:int;index;comment:订单ID"`
	GoodsId    int     `gorm:"type:int;index;comment:商品ID"`
	GoodsName  string  `gorm:"type:varchar(100);comment:商品名称"`
	GoodsImage string  `gorm:"type:varchar(200);comment:商品图片"`
	GoodsPrice float32 `gorm:"type:decimal(10,2);comment:商品价格"`
	Nums       int     `gorm:"type:int;comment:商品数量"`
}
